package com.cqw.common;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author: caoqingwen
 * @CreateTime: 2021-05-26 18:07
 * @Description:
 */
@Data
@NoArgsConstructor
public class Pagination {

    /**
     * 数据量
     */
    private Integer totalRow;

    private Integer pageSize;

    private Integer pageIndex;

    /**
     * 总页数
     */
    private Integer pageCount;


    public Pagination(Integer totalRow, Integer pageSize, Integer pageIndex) {
        this.totalRow = totalRow;
        this.pageSize = pageSize;
        this.pageIndex = pageIndex;
        if (pageIndex > 0 && pageSize > 0) {
            this.pageCount = (int) (Math.ceil(1.0 * totalRow / pageSize));
        }

        if (pageCount == null) {
            this.pageCount = 0;
        }
    }


}
